define((['jquery']),()=>{
    function registerLoad(){
        var username = document.querySelector('.username')
        var password =document.querySelector('.password')
        var  register= document.querySelector('.register')
        var span=document.querySelector('.yhm')
        var check=document.querySelector('.checkbox')
        // var type=check.checked
        var sAno=document.querySelector('.ma')
        register.onclick=()=>{
            if(username.value==''|| password.value=='' || check.checked==false){
                // return
                alert('请仔细阅读并同意用户协议')
            }
            else{
                if(check.checked==true){
                alert('正在跳转')
                location.href = '../html/login.html'
                // localStorage.setItem(username,password)
                localStorage.setItem('username',username.value)
                localStorage.setItem('password',password.value)
                console.log(username,password)
                }
                
            }
        }
        // 正则
        var yh=/^[\u2E80-\u9FFF]+$/
        var my=/^[a-z0-9_-]{6,18}$/
        username.onfocus = function(){
            span.innerHTML = '请输入正确的用户名'
        }
        username.onblur = function(){
            if(yh.test(username.value)){
                span.innerHTML = '√'
            }else{
                span.innerHTML = '用户名格式错误'  
            }
        }


        password.onfocus = function(){
            sAno.innerHTML = '请输入正确的密码'
        }
        password.onblur = function(){
            if(my.test(password.value)){
                sAno.innerHTML = '√'
            }else{
                sAno.innerHTML = '密码格式错误'  
            }
        }
    }
    return{
        registerLoad:registerLoad
    }
})